Index: src/libmdb/data.c
===================================================================
--- src/libmdb/data.c.orig
+++ src/libmdb/data.c
@@ -581,10 +581,13 @@ mdb_fetch_row(MdbTableDef *table)
 	do {
 		if (table->strategy==MDB_INDEX_SCAN) {
 		
-			if (!mdb_index_find_next(table->mdbidx, table->scan_idx, table->chain, &pg, (guint16 *) &(table->cur_row))) {
+			guint16 tmp = (guint16)table->cur_row;
+			if (!mdb_index_find_next(table->mdbidx, table->scan_idx, table->chain, &pg, &tmp)) {
+				table->cur_row = tmp;
 				mdb_index_scan_free(table);
 				return 0;
 			}
+			table->cur_row = tmp;
 			mdb_read_pg(mdb, pg);
 		} else {
 			rows = mdb_pg_get_int16(mdb,fmt->row_count_offset);
